﻿using Ekton_Manage_DomainCore.Aggregate;
using Ekton_Manage_DTO.APIRequestModels.SysUser;
using Ekton_Manage_IBusiness;
using Ekton_Manage_InfrastructureCore.Common;
using Ekton_Manage_InfrastructureCore.Repositories;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;

namespace Ekton_Manage_Web.Controllers
{
    /// <summary>
    /// 协议&隐私条款
    /// </summary>
    /// 
    [Route("api/[controller]/[action]")]
    [ApiController]
    [Authorize("Permission")]
    public class ApiAgreementController : ControllerBase
    {
        private readonly IBaseRepository<sys_msg, int> _repository;
        private readonly IApiAgreement _selectMsgPushList;
    

       public ApiAgreementController(IBaseRepository<sys_msg, int> repository, IApiAgreement selectMsgPushList)
        {
            _repository = repository;
            _selectMsgPushList = selectMsgPushList;
        }

        /// <summary>
        /// 查询隐私条款
        /// </summary>
        /// <remarks>
        /// deal为隐私条款字段
        /// </remarks>
        /// 
        [HttpGet]
        [AllowAnonymous]
        public async Task<Message> GetAllNewsList()
        {      
            return await _selectMsgPushList.SelectAgreement();            
        }

        /// <summary>
        /// 编辑隐私条款
        /// </summary>
        /// <param name="request"></param>
        /// <remarks>
        /// deal为隐私条款字段
        /// </remarks>
        /// <returns></returns>
        [HttpPut]
        public async Task<Message> PutAgreementList(ApiDtoAgreement request)
        {
            return await _selectMsgPushList.PutAgreementList(request);
        }
    }
}
